import axios from "axios";
import { ICompany, IFindRecruit, IKey, IRecruit } from "../types";

interface BaseRes {
  stat: string;
  message: string;
}

interface companyInfo extends BaseRes {
  result: ICompany;
}

interface CompanyList extends BaseRes {
  result: ICompany[];
}

interface recruitList extends BaseRes {
  result: IRecruit[];
}

interface keyList extends BaseRes {
  result: IKey[];
}

// 公司详细信息
export async function company(id: string) {
  const result = await axios.post<companyInfo>("/api/company/detail", {
    id: id,
  });
  return result.data;
}

// 热门企业
export async function hotCompany() {
  const result = await axios.post<CompanyList>("/api/company/home/hotCompany");
  return result.data;
}

// 热门职位
export async function hotrecruit(props: IFindRecruit) {
  const result = await axios.post<recruitList>(
    "/api/recruit/home/recruit",
    props
  );
  return result.data;
}

// 关键词
export async function hotKeys() {
  const result = await axios.post<keyList>("/api/keys/home/hotKeys");
  return result.data;
}
